package leetcode;

/**
 * Created by MtRider on 2021/10/23 22:36
 */
public class Palindrome {
    public static void main(String[] args) {
        System.out.println(isPalindrome("0P"));
    }

    public static boolean isPalindrome(String s) {
        boolean flag = true;
        if (s == null || ("").equals(s)) {
            return false;
        }
        char[] chars = s.toCharArray();
        String string = "";
        for (int i = 0; i < chars.length; i++) {
            if ((chars[i] >= 48 && chars[i] <= 57) || (chars[i] >= 65 && chars[i] <= 90) ||
                    (chars[i] >= 97 && chars[i] <= 122)) {
                string = string + chars[i];
            }
        }
        char attArr[] = string.toLowerCase().toCharArray();
        int length = attArr.length;
        for (int i = 0; i < length / 2; i++) {
            if (attArr[i] != attArr[length - 1 - i]) {
                flag = false;
                break;
            }
        }
        return flag;
    }
}
